/**
 * mbaobao.com Inc.
 * Copyright (c) 2011 All Rights Reserved.
 */
package com.peigen.web.depreciate.depreciate.dal.ibatis;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import com.peigen.web.depreciate.depreciate.dal.daointerface.DepreciateProductDAO;


// auto generated imports
import com.peigen.web.depreciate.depreciate.dal.dataobject.DepreciateProductDO;
import org.springframework.dao.DataAccessException;
import java.util.List;
import java.util.Map;
	import java.util.HashMap;
	
/**
 * An ibatis based implementation of dao interface <tt>com.peigen.web.depreciate.depreciate.dal.daointerface.DepreciateProductDAO</tt>.
 *
 * This file is generated by <tt>depreciate-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>paygw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/biz/dal/src/conf/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/depreciate_product.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>depreciate-dalgen</tt> 
 * to generate this file.
 *
 * @author peigen
 */ 
@SuppressWarnings({ "unchecked", "rawtypes" })

public class IbatisDepreciateProductDAO extends SqlMapClientDaoSupport implements DepreciateProductDAO {
	/**
	 *  Insert one <tt>DepreciateProductDO</tt> object to DB table <tt>depreciate_product</tt>, return primary key
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>insert into depreciate_product(id,track_category,product_name,product_serial_no,status,product_current_price,product_url,raw_add_time) values (?, ?, ?, ?, ?, ?, ?, ?)</tt>
	 *
	 *	@param depreciateProduct
	 *	@return String
	 *	@throws DataAccessException
	 */	 
    public String insert(DepreciateProductDO depreciateProduct) throws DataAccessException {
    	if (depreciateProduct == null) {
    		throw new IllegalArgumentException("Can't insert a null data object into db.");
    	}
    	
        getSqlMapClientTemplate().insert("MS-DEPRECIATE-PRODUCT-INSERT", depreciateProduct);

        return depreciateProduct.getId();
    }

	/**
	 *  Query DB table <tt>depreciate_product</tt> for records.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select id, track_category, product_name, product_serial_no, status, product_current_price, product_url, raw_add_time, raw_update_time from depreciate_product where (id = ?)</tt>
	 *
	 *	@param id
	 *	@return DepreciateProductDO
	 *	@throws DataAccessException
	 */	 
    public DepreciateProductDO findById(String id) throws DataAccessException {

        return (DepreciateProductDO) getSqlMapClientTemplate().queryForObject("MS-DEPRECIATE-PRODUCT-FIND-BY-ID", id);

    }

	/**
	 *  Query DB table <tt>depreciate_product</tt> for records.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select id, track_category, product_name, product_serial_no, status, product_current_price, product_url, raw_add_time, raw_update_time from depreciate_product where ((track_category = ?) AND (product_serial_no = ?))</tt>
	 *
	 *	@param trackCategory
	 *	@param productSerialNo
	 *	@return DepreciateProductDO
	 *	@throws DataAccessException
	 */	 
    public DepreciateProductDO findBySerialNoAndCategory(String trackCategory, String productSerialNo) throws DataAccessException {
        Map param = new HashMap();

        param.put("trackCategory", trackCategory);
        param.put("productSerialNo", productSerialNo);

        return (DepreciateProductDO) getSqlMapClientTemplate().queryForObject("MS-DEPRECIATE-PRODUCT-FIND-BY-SERIAL-NO-AND-CATEGORY", param);

    }

	/**
	 *  Query DB table <tt>depreciate_product</tt> for records.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select id, track_category, product_name, product_serial_no, status, product_current_price, product_url, raw_add_time, raw_update_time from depreciate_product</tt>
	 *
	 *	@param limitStart
	 *	@param pageSize
	 *	@return List<DepreciateProductDO>
	 *	@throws DataAccessException
	 */	 
    public List<DepreciateProductDO> loadAllPageList(int limitStart, int pageSize) throws DataAccessException {
        Map param = new HashMap();

        param.put("limitStart", new Integer(limitStart));
        param.put("pageSize", new Integer(pageSize));

        return getSqlMapClientTemplate().queryForList("MS-DEPRECIATE-PRODUCT-LOAD-ALL-PAGE-LIST", param);

    }

	/**
	 *  Update DB table <tt>depreciate_product</tt>.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>update depreciate_product set track_category=?, product_name=?, product_serial_no=?, status=?, product_current_price=?, product_url=? where (id = ?)</tt>
	 *
	 *	@param depreciateProduct
	 *	@return int
	 *	@throws DataAccessException
	 */	 
    public int updateForId(DepreciateProductDO depreciateProduct) throws DataAccessException {
    	if (depreciateProduct == null) {
    		throw new IllegalArgumentException("Can't update by a null data object.");
    	}


        return getSqlMapClientTemplate().update("MS-DEPRECIATE-PRODUCT-UPDATE-FOR-ID", depreciateProduct);
    }

	/**
	 *  Query DB table <tt>depreciate_product</tt> for records.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select id, track_category, product_name, product_serial_no, status, product_current_price, product_url, raw_add_time, raw_update_time from depreciate_product where (id = ?) for update</tt>
	 *
	 *	@param id
	 *	@return DepreciateProductDO
	 *	@throws DataAccessException
	 */	 
    public DepreciateProductDO selectForUpdate(String id) throws DataAccessException {

        return (DepreciateProductDO) getSqlMapClientTemplate().queryForObject("MS-DEPRECIATE-PRODUCT-SELECT-FOR-UPDATE", id);

    }

	/**
	 *  Delete records from DB table <tt>depreciate_product</tt>.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>delete from depreciate_product where ((product_serial_no = ?) AND (track_category = ?))</tt>
	 *
	 *	@param productSerialNo
	 *	@param trackCategory
	 *	@return int
	 *	@throws DataAccessException
	 */	 
    public int deleteBySerialNoForTest(String productSerialNo, String trackCategory) throws DataAccessException {
        Map param = new HashMap();

        param.put("productSerialNo", productSerialNo);
        param.put("trackCategory", trackCategory);

        return getSqlMapClientTemplate().delete("MS-DEPRECIATE-PRODUCT-DELETE-BY-SERIAL-NO-FOR-TEST", param);
    }

}